<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'language' => 'zh-TW',
    'modules' => [
        'sitemap' => [
            'class' => 'himiklab\sitemap\Sitemap',
            'models' => [
                // your models
                'common\models\Post',
                'common\models\Subject',
                'common\models\Note',
                'common\models\Sltopic',
                'common\models\Zytopic',
                'common\models\Shicai',
                'common\models\Zhongyao',
                'common\models\Catelog',
            ],
            'urls' => [
                // your additional urls
                [
                    'loc' => '/',
                    'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
                    'priority' => 0.9,
                ],
            ],
            'enableGzip' => true, // default is false
            'cacheExpire' => 43200, // 1 second. Default is 12 hours
        ],
    ],
    'components' => [
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
        'assetManager' => [
          'linkAssets' => true,
        ],
        'user' => [
            'identityClass' => 'common\models\Admin',
            'enableAutoLogin' => true,
        ],
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '/' => 'site/index',
                "<controller:\w+>/<id:\d+>" => "<controller>/view",
                //  特殊小范围的规则放前面，通用规则放最后
                //  note控制器规则
//                "shicai" => "shicai/index",
//                "shicai/<id:\d+>" => "shicai/view",
//                "sltopic" => "sltopic/index",
//                "sltopic/<id:\d+>" => "sltopic/view",
                "note" => "note/index",
                "note/<id:\d+>" => "note/view",
                "topic/<tag:\w+>" => "note/topic",
                "catelog" => "catelog/index",
                "catelog/<slug:\w+>" => "catelog/view",
                "page/<slug:\w+>" => "page/view",
                "site/<action:\w+>" => "site/<action>",
                "<controller:\w+>/<action:\w+>" => "<controller>/<action>",
                //  生成sitemap插件 https://github.com/himiklab/yii2-sitemap-module
                ['pattern' => 'map', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],

            ],
        ],
        // 国际化，多语言
        'i18n' => [
            'translations' => [
                'common' => [
                    'class' => 'yii\i18n\PhpMessageSource',
//                    'basePath' => '@common/messages',
                    'sourceLanguage' => 'en-US',
                    'fileMap' => [
                        'common' => 'common.php',
                        'app/error' => 'error.php',
                    ],
                ],
            ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // send all mails to a file by default. You have to set 
            // 'useFileTransport' to false and configure a transport 
            // for the mailer to send real emails. 
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.qiye.163.com',
                'username' => 'lilr@primeton.com',
                'password' => 'Llr139248',
                'port' => '25',
                'encryption' => 'tls',
            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['no-replay@dataing.net' => 'dataing.net']
            ],
        ],

    ],
    'params' => $params,
];
